var ajaxObject = function (url, callbackFunction) {
	var that=this;
	this.readyState = 0;
	this.updating = false;
	this.status = 0;
	this.onEventFunctions = Array();
	this.responseText = new String();
	this.statusText = new String();
	this.responseXML = new String();
//	this.statePopUp = new loadingDataPopUp("Uninitialized");
	this.abort = function() {
		if (that.updating) {
			that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
		}  
	} 
	this.update = function(passData,postMethod) {
		if (that.updating) {
			return false; 
		}
		that.AJAX = null;
		if (window.XMLHttpRequest) {
			that.AJAX=new XMLHttpRequest();
		} else {
			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (that.AJAX==null) {
			return false;
		} else {
			that.AJAX.onreadystatechange = function() {
				that.readyState = that.AJAX.readyState;
				if (that.AJAX.readyState==4) {
					that.updating=false;
					that.responseText = that.AJAX.responseText
					that.status = that.AJAX.status;
					that.statusText = that.AJAX.statusText;
					that.responseXML = that.AJAX.responseXML;
					that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
					that.AJAX=null;
				}
				that.onStateChanged(that.readyState);
			}
			that.updating = new Date();
			if (/post/i.test(postMethod)) {
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				that.AJAX.setRequestHeader("Content-Length", passData.length);
				that.AJAX.send(passData);
			} else {
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());
				that.AJAX.open("GET", uri, true);
				that.AJAX.send(null);
			}
			return true;
		}
	}  
	var urlCall = url;
	this.onStateChanged = function (state) {
		for (obj=0;obj<this.onEventFunctions.length;obj++){
			if(state == 1){
				this.onEventFunctions[obj].loadingData();
			} else if (state == 2){
				this.onEventFunctions[obj].loadedData();
			} else if (state == 3){
				this.onEventFunctions[obj].interactiveData();
			} else if (state == 4){
				this.onEventFunctions[obj].completeData();
			}
		}
	};
	this.callback = callbackFunction || function () {};
}
